Skip to content

Fix missing named-arg validation for compiled format strings#4638

Merged
vitaut merged 6 commits intofmtlib:masterfrom
jaeheonshim:fix-compile-arg-validation
Jan 4, 2026
Merged

Fix missing named-arg validation for compiled format strings#4638
vitaut merged 6 commits intofmtlib:masterfrom
jaeheonshim:fix-compile-arg-validation

Conversation

@jaeheonshim
Copy link
Copy Markdown
Contributor

Added DYNAMIC_NAMES type parameter to compile_format_string, which is set to true when runtime named arguments are present. Fixed missing named-arg validation by asserting that if DYNAMIC_NAMES is false, the arg_index produced by get_arg_index_by_name(arg_id_result.arg_id.name, Args{}) in the compile time parser must not be -1.

Also added a few tests under test/compile-error-test to verify intended behavior.

#4124

@jaeheonshim jaeheonshim force-pushed the fix-compile-arg-validation branch from 6bcf243 to 3c44f2d Compare December 30, 2025 01:47
Copy link
Copy Markdown
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Overall looks good, but please address the inline comments.

Comment thread test/compile-error-test/CMakeLists.txt Outdated
Comment thread include/fmt/compile.h Outdated
@jaeheonshim jaeheonshim requested a review from vitaut January 3, 2026 02:59
@vitaut vitaut merged commit 46a4599 into fmtlib:master Jan 4, 2026
41 checks passed
@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Jan 4, 2026

Merged, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants